<template>
	<view class="uni-steps">
		<view :class="[direction==='column'?'uni-steps__column':'uni-steps__row']">
			<view :class="[direction==='column'?'uni-steps__column-text-container':'uni-steps__row-text-container']">
				<view v-for="(item,index) in options" :key="index" @tap="goHmoe(item)">
					<!-- @tap="$tools.to('/pages/flow/filltab?stepId=' + item.id + '&name=' + item.flow_name)"  @tap="goHmoe(item.path)" -->
					<view :style="{color:index<=active?activeColor:deactiveColor}"
					
						:class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">0{{index + 1}}
					</view>
					<view :class="[direction==='column'?'uni-steps__column-text':'uni-steps__row-text']">
						<view :style="{color:index<=active?activeColor:deactiveColor}"
							:class="[direction==='column'?'uni-steps__column-title':'uni-steps__row-title']">{{item.flow_name}}</view>

						<!-- <view v-if="item.text !== '已填写'" class="" style="color: #FFBA00; font-size: 30rpx;">
							<text>{{item.text}}</text> <text class="cuIcon-right ml16"></text>
						</view> v-else -->
						<view class="" style="font-size: 30rpx;">
							<!-- <text v-if="active >= item.id"> 已填写</text>
							<text v-else>请填写</text>
							<text class="cuIcon-right"></text> -->
							<block v-if="active >= item.id">
								<text style="color: #717171; " > 已填写</text>
								<text style="color: #717171; " class="cuIcon-right"></text>
							</block>
							<block v-else>
								<text style="color: #FFBA00; " >请填写</text>
								<text style="color: #FFBA00; " class="cuIcon-right"></text>
							</block>
						</view>
					</view>
				</view>
			</view>
			
			<!-- content: ""
			createtime: 1623215531
			flow_name: "对接明细"
			id: 1 -->
			
			<view :class="[direction==='column'?'uni-steps__column-container':'uni-steps__row-container']">
				<view :class="[direction==='column'?'uni-steps__column-line-item':'uni-steps__row-line-item']"
					v-for="(item,index) in options" :key="index">
					<view
						:class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--before':'uni-steps__row-line--before']"
						:style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}">
					</view>
					<view :class="[direction==='column'?'uni-steps__column-check':'uni-steps__row-check']"
						v-if="index === active">
						<uni-icons :color="activeColor" type="checkbox-filled" size="14"></uni-icons>
					</view>
					<view class="box-show" v-else>
						<view :class="[direction==='column'?'uni-steps__column-circle':'uni-steps__row-circle']"
							:style="{backgroundColor:index<active?activeColor:deactiveColor}"></view>
					</view>
					<view
						:class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--after':'uni-steps__row-line--after']"
						:style="{backgroundColor:index<active&&index!==options.length-1?activeColor:index===options.length-1?'transparent':deactiveColor}">
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * Steps 步骤条
	 * @description 评分组件
	 * @tutorial https://ext.dcloud.net.cn/plugin?id=34
	 * @property {Number} active 当前步骤
	 * @property {String} direction = [row|column] 当前步骤
	 * 	@value row 横向
	 * 	@value column 纵向
	 * @property {String} activeColor 选中状态的颜色
	 * @property {Array} options 数据源，格式为：[{title:'xxx',desc:'xxx'},{title:'xxx',desc:'xxx'}]
	 */

	export default {
		name: 'UniSteps',
		props: {
			direction: {
				// 排列方向 row column
				type: String,
				default: 'row'
			},
			activeColor: {
				// 激活状态颜色
				type: String,
				default: '#7C6BD5'
			},
			deactiveColor: {
				// 未激活状态颜色
				type: String,
				default: '#9885F8'
			},
			active: {
				// 当前步骤
				type: Number,
				default: 0
			},
			options: {
				type: Array,
				default () {
					return []
				}
			} // 数据
		},
		data() {
			return {}
		},
		methods: {
			goHmoe(item) {
				// var init = item.id + 2
				// this.$emit('moreBtn',url)  <text v-if="active >= item.id"> 已填写</text>
				if (this.active >= item.id) {
					console.log('item==>', item);
					var id = uni.getStorageSync('flow_step')
					uni.navigateTo({
						url:'/pages/flow/stepList?id=' + item.id + '&text=' + 11
					})
					
					// 比点击 if (this.active >= item.id)
				} else {
					uni.navigateTo({
						url: '/pages/flow/filltab?stepId=' + item.id + '&name=' + item.flow_name
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-steps {
		/* #ifndef APP-NVUE */
		display: flex;
		width: 100%;
		/* #endif */
		/* #ifdef APP-NVUE */
		flex: 1;
		/* #endif */
		flex-direction: column;
	}

	.uni-steps__row {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
	}

	.uni-steps__column {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row-reverse;
	}

	.uni-steps__row-text-container {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: flex-end;
		margin-bottom: 8px;
	}

	.uni-steps__column-text-container {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		flex: 1;
	}

	.uni-steps__row-text {
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		flex: 1;
		flex-direction: column;
	}

	.uni-steps__column-text {
		padding: 10rpx 20rpx 80rpx 0rpx;
		// border-bottom-style: solid;
		// border-bottom-width: 1px;
		// border-bottom-color: $uni-border-color;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		// align-items: center;
		// flex-direction: column;
		justify-content: space-between;
	}

	.uni-steps__row-title {
		font-size: $uni-font-size-base;
		line-height: 16px;
		text-align: center;
	}

	.uni-steps__column-title {
		font-size: $uni-font-size-base;
		text-align: left;
		line-height: 18px;
	}

	.uni-steps__row-desc {
		font-size: 12px;
		line-height: 14px;
		text-align: center;
	}

	.uni-steps__column-desc {
		font-size: $uni-font-size-sm;
		text-align: left;
		line-height: 18px;
		padding: 10rpx 0 0 6rpx;
	}

	.uni-steps__row-container {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	.uni-steps__column-container {
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		width: 30px;
		flex-direction: column;
	}

	.uni-steps__row-line-item {
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		flex-direction: row;
		flex: 1;
		height: 14px;
		line-height: 14px;
		align-items: center;
		justify-content: center;
	}

	.uni-steps__column-line-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		flex: 1;
		align-items: center;
		justify-content: center;
	}

	.uni-steps__row-line {
		flex: 1;
		height: 1px;
		background-color: $uni-text-color-grey;
	}

	.uni-steps__column-line {
		width: 1px;
		background-color: $uni-text-color-grey;
	}

	.uni-steps__row-line--after {
		transform: translateX(1px);
	}

	.uni-steps__column-line--after {
		flex: 1;
		transform: translate(0px, 1px);
	}

	.uni-steps__row-line--before {
		transform: translateX(-1px);
	}

	.uni-steps__column-line--before {
		height: 6px;
		transform: translate(0px, -1px);
	}

	.uni-steps__row-circle {
		width: 5px;
		height: 5px;
		border-radius: 100px;
		background-color: $uni-text-color-grey;
		margin: 0px 3px;
	}

	.uni-steps__column-circle {
		width: 18rpx;
		height: 18rpx;
		border-radius: 100px;
		margin: 4px 0px 5px 0px;
		// box-shadow: 1rpx 2rpx 3rpx 3rpx rgba();
		background-color: $uni-text-color-grey;
	}

	.box-show {
		width: 30rpx;
		height: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #CBC2F7;
		border-radius: 50%;
	}

	.uni-steps__row-check {
		margin: 0px 6px;
	}

	.uni-steps__column-check {
		height: 14px;
		line-height: 14px;
		margin: 2px 0px;
	}
</style>
